package com.carhome.adapter;

import java.util.List;
import com.carhome.R;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.shizhefei.view.indicator.IndicatorViewPager.IndicatorFragmentPagerAdapter;

public class ArticleMainAdapter extends IndicatorFragmentPagerAdapter {
	private List<String> tabslist;
	private List<Fragment> fragmentLists;

	public ArticleMainAdapter(FragmentManager fragmentManager) {
		super(fragmentManager);
	}

	public void initAdapter(List<String> tabsString, List<Fragment> fragments) {
		tabslist = tabsString;
		fragmentLists = fragments;
	}

	public int getCount() {
		return tabslist.size();
	}

	@Override
	public Fragment getFragmentForPage(int position) {
		return fragmentLists.get(position);
	}

	@Override
	public View getViewForTab(int position, View convertView, ViewGroup container) {
		if (convertView == null) {
			convertView = LayoutInflater.from(container.getContext()).inflate(
					R.layout.article_tab_top, container, false);
		}
		TextView textView = (TextView) convertView;
		textView.setText(tabslist.get(position));
		textView.setPadding(30, 0, 30, 0);
		return convertView;
	}

}
